package cn.nbs.cart.entity;

import java.math.BigDecimal;

import cn.nbs.book.entity.Book;
import cn.nbs.user.entity.User;

public class CartItem {
	private String cartItemId;
	private int quantity;
	private Book book;
	private User user;
	
	/**
	 * 获取当前购物车条目的小计
	 * @return
	 */
	public double getSubTotal(){
		BigDecimal b1 = new BigDecimal(book.getCurrPrice()+"");
		BigDecimal b2 = new BigDecimal(quantity + "");
		BigDecimal sum = b1.multiply(b2);
		return sum.doubleValue();
	}
	
	
	
	
	@Override
	public String toString() {
		return "CartItem [cartItemId=" + cartItemId + ", quantity=" + quantity
				+ ", book=" + book + ", user=" + user + "]";
	}
	public CartItem() {
		super();
		// TODO Auto-generated constructor stub
	}
	public String getCartItemId() {
		return cartItemId;
	}
	public void setCartItemId(String cartItemId) {
		this.cartItemId = cartItemId;
	}
	public int getQuantity() {
		return quantity;
	}
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	public Book getBook() {
		return book;
	}
	public void setBook(Book book) {
		this.book = book;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public CartItem(String cartItemId, int quantity, Book book, User user) {
		super();
		this.cartItemId = cartItemId;
		this.quantity = quantity;
		this.book = book;
		this.user = user;
	}
	
	
}
